<?php
/**
 * 日志类
 *
 * @package default
 * @author 
 **/
class openapi_log
{
    /**
     * 
     *
     * @param  
     *
     * @return void
     * 
     * @author 张学会 <phlv@163.com>
     **/
    public function __construct()
    {
        $this->reqModel = app::get('openapi')->model('request_log');
        $this->resModel = app::get('openapi')->model('response_log');
    }
    /**
     * 请求日志
     *
     * @param  
     *
     * @return void
     * 
     * @author 张学会 <phlv@163.com>
     **/
    public function request($api_name,$task_id,$appParams,$responseData,$flag,$status,$msg,$original_task_id=null,$original_num=null)
    {
        $data['api_name'] = $api_name;
        $data['task_id'] = $task_id;
        $data['appParams'] = $appParams;
        $data['responseData'] = $responseData;
        $data['flag'] = $flag;
        $data['status'] = $status=='succ'?'succ':'fail';
        $data['msg'] = $msg;
        $data['createtime'] = time();
        //$data['last_modified'] = time();
        $data['next_retry_time'] = time();
        $data['original_num'] = $original_num;
        $data['original_task_id'] = $original_task_id;
        $this->reqModel->save($data);

    }

    /**
     * 响应日志
     *
     * @param  
     *
     * @return void
     * 
     * @author 张学会 <phlv@163.com>
     **/
    public function response($api_name,$task_id,$appParams,$responseData,$flag,$status,$msg,$original_num=null)
    {
        $data['api_name'] = $api_name;
        $data['task_id'] = $task_id;
        $data['appParams'] = $appParams;
        $data['responseData'] = $responseData;
        $data['flag'] = $flag;
        $data['status'] = $status?'succ':'fail';
        $data['createtime'] = time();
        $data['last_modified'] = time();
        $data['original_num'] = $original_num;
        #echo('<pre>');print_r($data);exit;
        $this->resModel->save($data);
    }
} // END class openapi_log




